package com.dify.tool.common.exception;

import com.dify.tool.common.constant.BaseStatus;

/**
 * @author shl
 * @date 2024-06-26
 * @description
 */
public class BizException extends RuntimeException {
    private String code;
    private String message;

    public BizException(BaseStatus baseStatus) {
        this(baseStatus.getCode(), baseStatus.getMessage());
    }

    public BizException(String code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public static BizException ex(BaseStatus baseStatus) {
        return ex(baseStatus.getCode(), baseStatus.getMessage());
    }

    public static BizException ex(String code, String message) {
        return new BizException(code, message);
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }
}
